package cn.iocoder.yudao.module.handguard.dal.mysql.productaccessitem;

import java.util.*;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.module.handguard.dal.dataobject.productaccessitem.ProductAccessItemDO;
import org.apache.ibatis.annotations.Mapper;
import cn.iocoder.yudao.module.handguard.controller.admin.productaccessitem.vo.*;
import org.apache.ibatis.annotations.Param;

/**
 * 产品准入项 Mapper
 *
 * @author 芋道源码
 */
@Mapper
public interface ProductAccessItemMapper extends BaseMapperX<ProductAccessItemDO> {

    default PageResult<ProductAccessItemDO> selectPage(ProductAccessItemPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<ProductAccessItemDO>()
                .eqIfPresent(ProductAccessItemDO::getProductAccessId, reqVO.getProductAccessId())
                .likeIfPresent(ProductAccessItemDO::getClassName, reqVO.getCategoryName())
                .eqIfPresent(ProductAccessItemDO::getCategory, reqVO.getCategory())
                .likeIfPresent(ProductAccessItemDO::getTypeNames, reqVO.getTypeName())
                .betweenIfPresent(ProductAccessItemDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(ProductAccessItemDO::getId));
    }

    default List<ProductAccessItemDO> selectList(ProductAccessItemExportReqVO reqVO) {
        return selectList(new LambdaQueryWrapperX<ProductAccessItemDO>()
                .eqIfPresent(ProductAccessItemDO::getProductAccessId, reqVO.getProductAccessId())
                .likeIfPresent(ProductAccessItemDO::getClassName, reqVO.getCategoryName())
                .eqIfPresent(ProductAccessItemDO::getCategory, reqVO.getCategory())
                .likeIfPresent(ProductAccessItemDO::getTypeNames, reqVO.getTypeName())
                .betweenIfPresent(ProductAccessItemDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(ProductAccessItemDO::getId));
    }

    void deleteByPid(Long id);

    List<ProductAccessItemDO> getProductAccessItemList(@Param("id") Long id);


    Long getPid(@Param("typeName") String typeName,@Param("className") String className);
}
